{template common/header}
{template misc/tip_upload}
<script type="text/javascript" src="{baseurl}assets/js/swfupload.js"></script>
<script type="text/javascript" src="{baseurl}assets/js/swfupload.queue.js"></script>
<script type="text/javascript" src="{baseurl}themes/$theme/js/handlers.js"></script>

<div class="container publish-normal">
<div class="tabbable tabs-left">
	<div class="publish-left">
		<ul class="nav nav-tabs" id="publishTab">
		   	<li class="active">
		     <a href="#website_fetch" data-toggle="tab" class="website_fetch" data-action="switchPublish" data-params="website_fetch"><img alt="{lang post_share}" class="fig" src="{baseurl}assets/img/publish-fetch.png">{lang post_share}</a>
		   	</li>
		</ul>
		<!--<div class="pull-left alert alert-info clearfix">
				{lang tip_post_share} 
		</div>-->
		
		<div class="pull-left alert alert-info mt20">
				{lang tip_post_share_warning} 
		</div>
	</div>
	<div class="tab-content">  
	<form id="publish_form" action="{url share/post?act=save}" method="post" data-editorid="publish_editor">
		<div class="pzuimg-operation cls">
			<div id="uploadbtn"></div>
			{if $allowfetch}
			<a href="javascript:;" id="remoteImgFetch" class="publish-fetch ml20"></a>
			{/if}
			{if $allowvideo}
			<a href="javascript:;" id="remoteVideoFetch" class="publish-video ml20"></a>  
			{/if}
			<div class="pull-right alert mb0">
				{lang tip_max_attach_num}$allowmaxnum {lang tip_max_attach_size}{echo sizecount($maxattachsize)}{lang tip_max_attach_sizea}
			</div>
		</div>
		<div class="pzuimg-progress" id="divFileProgressContainer"></div>
		<div class="alert alert-info hide" id="fetchFileProgressContainer"></div>
		<div class="pzuimg-view hide mt10 pzuimg-thumbs" id="pzuimg-thumbs"></div>
		<div class="well form-inline"  id="normalshare-form">
			<div class="input-prepend">
					<span class="add-on">{lang share_title}</span><input type="text" name="title" class="span3" id="publish_title" min-length="{$shareSetting['title_range_s']}" max-length="{$shareSetting['title_range_l']}" placeholder="{lang share_title_tip}"/>
			</div>
			<div class="input-prepend first-div category_select_list ml10" id="popcategory" data-init="0" data-find-album="1">
				<input id="category_select_id" name="category_id" type="hidden" class="select_id category_select_id" value="{if $rootCategories[0]}{$rootCategories[0]['category_id']}{/if}">
				<input name="category_name" type="hidden" class="select_title" value="{if $rootCategories[0]}{$rootCategories[0]['category_name_cn']}{/if}">
				<span class="add-on">{lang category}</span><a href="javascript:void(0);" class="btn category-popbutton"><span class="select_title">{if $rootCategories[0]}{$rootCategories[0]['category_name_cn']}{else}{lang tip_plsselect}{/if}</span> <span class="caret ml10"></span></a>
			</div>
			<div class="input-prepend second-div album_select_list ml10" data-init="0">
				<input class="album_select_id" name="album_id" type="hidden">
				<span class="add-on">{lang album}</span><a href="javascript:void(0);" class="btn" data-action="albumItemPopup" data-params="normalshare-form"><span class="album_select_title">{lang loading}</span> <span class="caret ml10"></span></a>
				<ul class="btn-select">
					<li class="create_board" data-id="create_board">
					<input type="text" class="album_name span2" data-id="album_name">
					<span class="album_select_create btn btn-puzz" data-action="albumPopCreate" data-params="normalshare-form">{lang create_new}</span>
					</li>
				</ul>
			</div>
			{if $settings['price']}
			<div class="input-prepend ml10 clearfix">
		        <span class="add-on">$settings['priceunit']</span><input type="text" name="price" class="input-small price" id="price" placeholder="{lang share_price}"/>
			</div>
			{/if}
			<div class="publish-editor">
			{template editor/editor}
			</div>
			<div class="publish-tags mt10">
				<div class="input-prepend pull-left">
					<span class="add-on txtarea-label">{lang tag}</span><textarea id="publish-tagsarea" data-default="" rows="3" name="keyword"></textarea>
				</div>
				<div class="input-prepend pull-left ml20">  
					<span class="add-on txtarea-label">{lang recommend}</span><div class="txtarea-div tags"><ul id="publish-tagslist" data-target-id="publish-tagsarea" data-maxselected="$shareSetting['tagnum']" class="tags_list"></ul></div>
				</div>
			</div>
			<div class="publish-tags mt10">
				<div class="input-prepend pull-left clearfix">
			        <span class="add-on"><i class="icon-globe"></i></span><input type="text" name="url" class="span8 refurl" id="url" placeholder="{lang url}"/>
				</div>
			</div>
		</div> 
		<input type="hidden" name="uploadimgs"/>
		<input type="hidden" name="uploadfiles"/>
		<input type="hidden" name="videos"/>
		<input type="hidden" name="fetchs"/>
		<input type="hidden" name="text"/>
		<input type="hidden" name="topicid" value="$topicid"/>
		<input type="hidden" name="groupid" value="$groupid"/>
		<input type="hidden" name="storeid" value="$storeid"/>
		<input type="hidden" name="storechannel" value="$storechannel"/>
		<div class="buttons">
    		<button type="submit" class="btn btn-large btn-info pull-right mr10 submit-btn" data-loading-text="{lang tip_process_post}">{lang post_share}</button>
    	</div>
	</form>
	</div>
</div>
</div> 

<script type="text/javascript">
$(document).ready(function($) {
	//getCategories('normalshare-form', null, null);
	getAlbums('normalshare-form','{$rootCategories[0]['category_id']}',null,null);
	getTags('{$rootCategories[0]['category_id']}','#normalshare-form .tags_list');
	$('.category-popbutton').popcategory({
		top: '0px',
		left: '0px',
		width: '370px',
		targetid: 'popcategory',
		tpl: 'deepcategory'},function(cid){
			getAlbums('normalshare-form',cid,null,null);
			getTags(cid,'#normalshare-form .tags_list');
		});
	var editor = $.oEditor('publish_editor',{
		id : 'publish_editor', 
		className : 'editor',
		initialtext : '{$inittxt}',
		editorcurrentheight : 300, 
		editorminheight : 300,
		editorcontroltop:false,
		editorid : 'editor'
	});
	{if $allowfetch}
	$('#remoteImgFetch').fetchRemote({
		url: '{url channel/imagefetch}',
		popuptpl: 'address_input',
		thumbtpl:'swfupload_thumb_fetch',
		thumbdiv:'pzuimg-thumbs',
		titleinput:'publish_title',
		editorid:'publish_editor',
		duration: 1000
	});
	{/if}
	{if $allowvideo}
	$('#remoteVideoFetch').fetchRemote({
		url: '{url channel/videofetch}',
		popuptpl: 'address_input',
		thumbtpl:'video_thumb',
		thumbdiv:'pzuimg-thumbs',
		titleinput:'publish_title',
		editorid:'publish_editor',
		duration: 1000
	});
	{/if}
});
var postParams = getcookiearray();
postParams['width']='80';
postParams['uploadToken']='{$uploadToken}';

var swfu = new SWFUpload({upload_url: '{url attachment/upload}',
	post_params: postParams,
	file_size_limit : "{echo $maxattachsize/1024}",
	file_types : "{$allowtype}",
	file_types_description : "{$allowtype_desc}",
	file_upload_limit : {$allowmaxnum},
	file_queue_limit : 0,
	file_queued_handler :fileQueued,
	file_queue_error_handler : fileQueueError,
	file_dialog_complete_handler : fileDialogComplete,
	upload_progress_handler : uploadProgress,
	upload_error_handler : uploadError,
	upload_success_handler : uploadSuccess,
	upload_complete_handler : uploadComplete,
	button_image_url : "{baseurl}assets/js/upload.png",
	button_placeholder_id : "uploadbtn",
	button_width: 100,
	button_height: 30,
	button_window_mode: "transparent",
	flash_url : "{baseurl}assets/js/swfupload.swf",
	custom_settings : {
		editorid : "publish_editor",
		upload_target : "divFileProgressContainer",
		thumb_target : "pzuimg-thumbs",
		thumbimg_tpl : "swfupload_thumb",
		thumbothers_tpl : "swfupload_thumb_others",
		thumberror_tpl : "swfupload_thumb_error",
		duration: 1000
	},
	debug: false
});
</script>

{template common/footer}